package com.izerofx;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.zbus.mq.server.MqServer;
import org.zbus.mq.server.MqServerConfig;

/**
 * 类名称：Application<br>
 * 类描述：应用主类<br>
 * 创建人：qinjiaxue<br>
 * 创建时间：2016年11月2日 下午5:16:32<br>
 *
 * @version v1.0
 *          <p>
 *          启动zbus服务
 */
@SpringBootApplication
public class WenKuApplication {
    private static Log log = LogFactory.getLog(WenKuApplication.class);


    private static void startZbusServer() {
        MqServerConfig config = new MqServerConfig();
        config.serverPort = 15555;

        //config.storePath = "/data/wenku_upoald/store";
        config.storePath = "./store";
        config.serverName = "wenku-demo";
        try {
            new MqServer(config).start();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    public static void main(String[] args) {
        // 启动zbus
        startZbusServer();
        log.info("===============zubss start............====================");
        SpringApplication.run(WenKuApplication.class, args);

    }
}

//项目改为war包启动时使用
/*public class WenKuApplication extends SpringBootServletInitializer {

    private static Log log = LogFactory.getLog(WenKuApplication.class);

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(WenKuApplication.class);
    }


    private static void startZbusServer() {
        MqServerConfig config = new MqServerConfig();
        config.serverPort = 15555;

       // config.storePath = "./store";
        config.storePath = "/data/wenku_upoald/store";
        config.serverName = "wenku-demo";
        try {
            new MqServer(config).start();
            log.info("===============zubss start............====================");
        } catch (Exception e) {
            log.info("===============zubss failed............====================");
            e.printStackTrace();
            log.info(e.getMessage());
        }
    }

    public static void main(String[] args) {
        startZbusServer();
        log.info("===============server start............====================");
        SpringApplication.run(WenKuApplication.class, args);
    }
}*/
